/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package struts.impl;

import java.math.BigInteger;
import java.util.ArrayList;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import struts.Header;
import struts.StrutsPackage;
import struts.TagText;
import struts.tools.Data;
import struts.tools.IVisitor;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Header</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link struts.impl.HeaderImpl#getLevel <em>Level</em>}</li>
 *   <li>{@link struts.impl.HeaderImpl#getTagText <em>Tag Text</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class HeaderImpl extends TagElementImpl implements Header {
	/**
	 * The default value of the '{@link #getLevel() <em>Level</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLevel()
	 * @generated
	 * @ordered
	 */
	protected static final BigInteger LEVEL_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getLevel() <em>Level</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getLevel()
	 * @generated
	 * @ordered
	 */
	protected BigInteger level = LEVEL_EDEFAULT;

	/**
	 * The cached value of the '{@link #getTagText() <em>Tag Text</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTagText()
	 * @generated
	 * @ordered
	 */
	protected TagText tagText;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected HeaderImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return StrutsPackage.Literals.HEADER;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public BigInteger getLevel() {
		return level;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setLevel(BigInteger newLevel) {
		BigInteger oldLevel = level;
		level = newLevel;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.HEADER__LEVEL, oldLevel, level));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TagText getTagText() {
		return tagText;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTagText(TagText newTagText, NotificationChain msgs) {
		TagText oldTagText = tagText;
		tagText = newTagText;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StrutsPackage.HEADER__TAG_TEXT, oldTagText, newTagText);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTagText(TagText newTagText) {
		if (newTagText != tagText) {
			NotificationChain msgs = null;
			if (tagText != null)
				msgs = ((InternalEObject)tagText).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StrutsPackage.HEADER__TAG_TEXT, null, msgs);
			if (newTagText != null)
				msgs = ((InternalEObject)newTagText).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StrutsPackage.HEADER__TAG_TEXT, null, msgs);
			msgs = basicSetTagText(newTagText, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StrutsPackage.HEADER__TAG_TEXT, newTagText, newTagText));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case StrutsPackage.HEADER__TAG_TEXT:
				return basicSetTagText(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case StrutsPackage.HEADER__LEVEL:
				return getLevel();
			case StrutsPackage.HEADER__TAG_TEXT:
				return getTagText();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case StrutsPackage.HEADER__LEVEL:
				setLevel((BigInteger)newValue);
				return;
			case StrutsPackage.HEADER__TAG_TEXT:
				setTagText((TagText)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case StrutsPackage.HEADER__LEVEL:
				setLevel(LEVEL_EDEFAULT);
				return;
			case StrutsPackage.HEADER__TAG_TEXT:
				setTagText((TagText)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case StrutsPackage.HEADER__LEVEL:
				return LEVEL_EDEFAULT == null ? level != null : !LEVEL_EDEFAULT.equals(level);
			case StrutsPackage.HEADER__TAG_TEXT:
				return tagText != null;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (level: ");
		result.append(level);
		result.append(')');
		return result.toString();
	}
	/**
	 * @generated NOT
	 */
	/**
	 * @generated NOT
	 */
	@Override
	public void accept (IVisitor visitor,Data data){
		visitor.visit(this, data);
	}
} //HeaderImpl
